<include file="Public/head"/>
<link href="__PUBLIC__/qwadmin/css/shen/shen.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/qwadmin/css/Ku/add.css" rel="stylesheet" type="text/css" />

<body class="no-skin">
<style>


#tet th{
    text-align: center;
    font-size: 18px;
}
#tet td{
    text-align: center;
}

#divv input{
    margin:0px 5px;
}
.dds input{
    margin:0px 5px;
}


        .td button{
            margin-left: :50%;
        }
        #ban{
            width:75%;
            margin:40px auto;
            border: 1px solid #ccc;
            /*padding: 0 -1000px;*/
            box-shadow: 5px 5px 30px #888888;
        }
        #ban table{
            width:90%;
            margin:20px auto;
        }


</style>
<include file="Public/header"/>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <include file="Public/sidebar"/>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <include file="Public/breadcrumbs"/>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">
                <include file="Public/set"/>
                    

                    



                    <div id="ban" style="margin-top:10px;">
                            <h2 style="text-align:center;"><b>库存信息展示</b></h2><br>

                            <div class="row" style="margin:0px 20px;">
                            <form class="form-inline"  id="formId">
                               
                                <label class="inline">物品搜索:</label>
                                
                                <input type="text" name="wname" class="form-control">
                                <!-- <input type="hidden" name="x_type" value="1" class="form-control"> -->
                               
                                <div  class="btn btn-purple btn-sm" onclick="bsou()">
                                    <span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
                                    Search
                                </div>
                                 <div class='btn btn-info' id='bfan' style='width:100px;height:30px;line-height:10px;display:none;'>返回上一级</div>
                                 <!-- <div class='btn btn-info' id='bfen' style='width:120px;height:30px;line-height:10px;'>返回选择</div> -->
                            </form>
                           
                           
                         
                        </div>
                        <div style="float:right;margin-top:-50px;">
                             <form method="post" action="{:U('Ku/eadd')}" enctype="multipart/form-data">
                                <label class="inline"><b>库存导入</b>:</label><input  type="file" name="file" />
                                <input type="submit"  value="导入"   />
                            </form>
                        </div>
                        
                            <table class="table table-bordered" id="tet" style="margin-top:30px;">
                                <tr>
                                    <th class="center" >编号</th>
                                    <th class="center">物品名称</th>
                                    <th class="center">规格</th>
                                    <th class="center">剩余数量</th>
                                    <th class="center">单价</th>
                                    <th class="center" id="le">物品类型</th>
                                    <th class="center">金额</th>
                                    <th class="center">操作</th>

                                </tr>
                                <volist name="list" id="vo">
                                <input type="hidden" name='id' value="{$vo.id}">
                                <tr id="tr">
                                    <td class="center">{$vo.id}</td>
                                    <td class="center">{$vo.name}</td>
                                    <td class="center">{$vo.gui}</td>
                                    <td class="center"><input type="text" name="number" value="{$vo.number}" style="width:60px;">/{$vo.com}</td>
                                    <!-- <td class="center" style="display:none">{$vo.number}</td> -->
                                    <!-- <td class="center" style="display:none"><input type="hidden" name="x_type" value="{$vo.x_type}"></td> -->
                                    <!-- <td class="center" style="display:none"><input type="hidden" name="unit" value="{$vo.unit}"></td> -->
                                    <td class="center"><input type="text" name="unit" value="{$vo.unit}" style="width:60px;">/元</td>
                                    <!-- <td class="center" style="display:none"><input type="hidden" name="type" value="0"></td> -->
                                    <td class="center">
                                        <?php if($vo['x_type'] == '1'): ?>
                                            <b style="color:#00DB00">办公用品</b>
                                        <?php else: ?>
                                            <?php if($vo['x_type'] == 2): ?>
                                                <b style="color:#EEB422;">劳保用品</b>
                                            <?php else: ?>
                                                <?php if($vo['x_type'] == 3): ?>
                                                    <b style="color:#DC143C;">招待用品</b>
                                                <?php endif ?>
                                            <?php endif ?>
                                        <?php endif ?>
                                    </td>
                                    <td class="center">{$vo.zong}   /元</td>
                                    <td class="center">
                                    <button class="xiu" style="color:#000;" onclick="xiu({$vo.id},this)">修改</button>
                                    <button class="jujue"  onclick="del({$vo.id},this)">删除</button>
                                    </td>


                                </tr>




                            </volist> 
                            
                            </table>
                          
                          <div style="text-align:center;" id="page">{$page}</div>                
                          


                    </div>  
                   




            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <include file="Public/footer"/>

</div><!-- /.main-container -->

<include file="Public/footerjs"/>
<!-- inline scripts related to this page -->
<script src="__PUBLIC__/layer/layer.js"></script>
<script src="__PUBLIC__/jquery-1.7.2.min.js"></script>

<script>
    //办公用品搜索
    function bsou()
    {
       
        $.ajax({
            type: "POST",
            url:"{:U('Ku/sou')}",
            data:$('#formId').serialize(),// 要提交的表单 
            success: function(data) {
                
                 if (data != 1111) {
                    $('td').remove();
                        
                    for (var i = 0; i < data.length; i++) {
                        // console.log(data);
                        $("<tr><td class='center'>"+data[i].id+"</td><td class='center'>"+data[i].name+"</td><td class='center'>"+data[i].gui+"</td><td class='center'><input type='text' name='number' value='"+data[i].number+"' style='width:60px;'>/"+data[i].com+"</td><td class='center'><input type='text' name='unit' value='"+data[i].unit+"' style='width:60px;'>/元</td><td style='display:none;'></td><td class='center'><div class='btn-default' onclick='xiu("+data[i].id+",this)' style='color:#fff;cursor:pointer;box-shadow: 5px 5px 10px #888888;'>修改</div></td></tr>").appendTo('#tet');
                        $('#le').remove();
                        $('#bfan').show();
                        $('#page').hide();
                    }
                   
                    
               }else{
                    $('td').remove();
                    $("<td class='center' colspan='6' id='bmei'><h2>没有搜索到!!!</h2></td>").appendTo('#tr');
                    $('#bfan').show();
                    $('#page').hide();
               }
               
              
            }
        });
    }



function xiu(id,obj)
{
   
    var unit = $(obj).parent().prev().prev().children().val();
    var number = $(obj).parent().prev().prev().prev().children().val();
     // console.log(unit);
     // console.log(id);
     // console.log(number);
    $.ajax({
            type: "POST",
            url:"{:U('Ku/xiu')}",
            data:{'id':id,'unit':unit,'number':number},// 要提交的表单 
            success: function(data) {
              // console.log(data);
              if (data = '111') {
                layer.msg('修改成功!', {icon: 1});
                history.go(0);
              }else{
                layer.msg('修改失败!', {icon: 2});
              }
            }
        });
}




function del(id,obj)
{
	// console.log(id);
	$.ajax({
        type: "POST",
        url:"{:U('Ku/del')}",
        data:{'id':id},// 要提交的表单 
        success: function(data) {
          // console.log(data);
          if (data = '1111') {
            layer.msg('删除成功!', {icon: 1});
            history.go(0);
          }else{
            layer.msg('删除失败!', {icon: 2});
          }
        }
    });
}





    //返回所有列表
   $('#bfan').click(function(){
          history.go(0); 
   })
 </script>
          


</body>

</html>
